From 74de1839a4ebf88a22e6e21bcf2ad8403ca5d31d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 2 Sep 2010 01:58:48 +0200 Subject: [PATCH] GtkStyleSet: Set an empty default_value if none is provided. --- gtk/gtkstyleset.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/gtk/gtkstyleset.c b/gtk/gtkstyleset.c index 101925a1cc..755d66e1b0 100644 --- a/gtk/gtkstyleset.c +++ b/gtk/gtkstyleset.c @@ -355,6 +355,8 @@ gtk_style_set_register_property (const gchar *property_name, g_value_init (&new.default_value, G_VALUE_TYPE (default_value)); g_value_copy (default_value, &new.default_value); } + else + g_value_init (&new.default_value, type); if (parse_func) new.parse_func = parse_func; @@ -650,7 +652,7 @@ gtk_style_set_get_property (GtkStyleSet *set, val = property_data_match_state (prop, state); - if (!val && G_IS_VALUE (&node->default_value)) + if (!val) val = &node->default_value; g_return_val_if_fail (G_IS_VALUE (val), FALSE); @@ -686,6 +688,7 @@ gtk_style_set_get_valist (GtkStyleSet *set, PropertyNode *node; PropertyData *prop; gchar *error = NULL; + GValue *val = NULL; node = property_node_lookup (g_quark_try_string (property_name)); @@ -698,36 +701,22 @@ gtk_style_set_get_valist (GtkStyleSet *set, prop = g_hash_table_lookup (priv->properties, GINT_TO_POINTER (node->property_quark)); - if (!prop && !G_IS_VALUE (&node->default_value)) - { - GValue *empty_value = { 0 }; + if (prop) + val = property_data_match_state (prop, state); - g_warning ("No value for style property \"%s\"", property_name); + if (!val) + val = &node->default_value; - g_value_init (&empty_value, node->property_type); - G_VALUE_LCOPY (&empty_value, args, 0, &error); - } - else + if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) { - GValue *val = NULL; - - if (prop) - val = property_data_match_state (prop, state); + g_return_if_fail (node->property_type == GDK_TYPE_COLOR); - if (!val && G_IS_VALUE (&node->default_value)) + if (!resolve_color (set, val)) val = &node->default_value; - - if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR) - { - g_return_if_fail (node->property_type == GDK_TYPE_COLOR); - - if (!resolve_color (set, val)) - return; - } - - G_VALUE_LCOPY (val, args, 0, &error); } + G_VALUE_LCOPY (val, args, 0, &error); + if (error) { g_warning ("Could not get style property \"%s\": %s", property_name, error); -- 2.30.2